package com.sharein.auth.actions;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sharein.auth.beans.User;
import com.sharein.auth.business.UserManager;

public class SendEmail implements Action{

	@Override
	public boolean execute(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		String shareinID = request.getParameter("shareinID");
		User user = UserManager.getUser(shareinID);
		String host = "smtp.gmail.com";
		String from = "otm.ben@gmail.com";
		String password = "327788aa";
		String personal = "Sharein";
		String[] recipients = new String[]{user.getEmail()};
		String subject = "Password recovery !";
		String[] bodys = new String[]{"Hi " + user.getFullname() + ",\n\nYour password is: " + user.getPassword()
				+ "\n\nCordially, Sharein."};
		UserManager.sendEmail(host, from, password, personal, recipients, subject, bodys, null);
		return true;
	}

}
